package com.woniuxy.dao;

import com.woniuxy.dto.CarDto;
import com.woniuxy.entity.Car;
import com.woniuxy.entity.CarType;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CarMapper {
    /**
     * 条件查询分页查询所有
     * @param carNumber
     */
    List<CarDto> findAll(String carNumber);
    /**
     * 判断是否存在
     */
    @Select("select * from car where car_number = #{carNumber}")
    Car findByCar(String carNumber);

    /**
     * 添加
     * @param car
     * @return
     */
    @Insert("insert into car values(null,#{carTypeId},#{carNumber},#{frameNumber},#{motorNumber},#{dateRegistration},#{state},#{carUse},#{remarks})")
    int save(Car car);

    /**
     * 修改
     * @param car
     * @return
     */
    int updateById(Car car);
    /**
     * 删除
     */
    @Delete("delete from car where id=#{id}")
    int deleteById(Integer id);
    /**
     * 批量删除
     *
     */
    int deleteBatch(@Param("ids") String[] ids);

    /**
     * 批量添加数据
     */
    int insertBatch(List<CarDto> carList);


    /**
     * 远程查找所有车架返回下拉框
     */
    @Select("select * from car where frame_number like concat('%',#{frameNumber}, '%')")
    List<Car> findAllFrameNumber(String frameNumber);
    /**
     * 远程查找所有车牌号返回下拉框
     */
    @Select("select * from car where car_number like concat('%',#{carNumber}, '%')")
    List<Car> findAllCarNumber(String carNumber);

    /**
     *
     */
    @Select("select * from car")
    List<Car> findListCar();
}
